using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Xml;
using System.Web.Services.Protocols;

public partial class createRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            getOrganizationalUsers();
        }
    }

    private void getOrganizationalUsers()
    {
   
        XmlDocument xmldoc = new XmlDocument();

        xmldoc.LoadXml(RequestXML.searchLDAPRequest);
        xmldoc.SelectSingleNode("//*[local-name()='dn']").InnerText = "cn=organizational users," + Request.QueryString["organizationdn"];
        

        String searchldapResponse=Util.run(xmldoc.OuterXml);

        
        xmldoc.LoadXml(searchldapResponse);



        XmlNodeList userlist = xmldoc.SelectNodes("//*[local-name()='tuple']");
        XmlDocument tmpdoc = new XmlDocument();
        foreach (XmlNode usernode in userlist)
        {
            tmpdoc.LoadXml(usernode.Clone().OuterXml);
            String dn = tmpdoc.SelectSingleNode("//*[local-name()='entry']/@*[local-name()='dn']").InnerText;
            String description = tmpdoc.SelectSingleNode("//*[local-name()='entry']//*[local-name()='description']//*[local-name()='string']").InnerText;

            DropDownList1.Items.Add(new ListItem(description, dn));
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        XmlDocument xmldoc = new XmlDocument();
        xmldoc.LoadXml(RequestXML.executeProcess);

        xmldoc.SelectSingleNode("//*[local-name()='receiver']").InnerText = "ASP Business Process Model";
        xmldoc.SelectSingleNode("//*[local-name()='MsgFromUser']").InnerText = TextBox1.Text;
        xmldoc.SelectSingleNode("//*[local-name()='Managerdn']").InnerText = DropDownList1.SelectedItem.Value;

        Util.run(xmldoc.OuterXml);
    }
}
